/**
 * [OElove] (C)2010-2099 oelove.com Inc.
 * Email: service@phpcoo.com，phpcoo@qq.com
 * This is not a freeware, use is subject to license terms
 * $ LastTime 2017.02.13 Update by CL $
*/
$(function(){

	//弹出支付窗
	$(document).on("click", "[f='but_pay_party']", function(){
		$_id = $(this).attr("data-id");
		$width = $(this).attr("data-width");
		if (typeof($width) == "undefined") {
			$width = 690;
		}
		$height = $(this).attr("data-height");
		if (typeof($height) == "undefined") {
			$height = 500;
		}
		$_url = _ROOT_PATH+"index.php?m=user&c=party&a=pay&id="+$_id+"&r="+get_rndnum(8);
		oeShadeBox("pop_pay_party", "ajax", $_url, $width, $height);
	});

	//选择支付方式
	$(document).on("click", "[f='sel_party_payment']", function(){
		$("._list_lineserv_pay ul li").removeClass("current");
		$(this).addClass("current");
		$_sdkid = $(this).attr("data-sdkid");
		$_sdkname = $(this).attr("data-sdkname");
		
		$("#sdkid").val($_sdkid);
		$("#sdkname").val($_sdkname);
	});
	
	//提交支付
	$(document).on("click", "[f='but_party_pay_submit']", function(){
		$_sdkid = $("#sdkid").val();
		$_sdkname = $("#sdkname").val();
		if ($_sdkid.length == 0) {
			ToastShow("请选择支付方式");
			return false;
		}
		$_id = $(this).attr("data-id");
		$.ajax({
			type: "POST",
			url: _OE_FILE+"&c=party",
			cache: false,
			data: {
					a:"confirmpay", sdkid:$_sdkid, sdkname:$_sdkname, id:$_id, r:get_rndnum(8)
			},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					window.location.href = _ROOT_PATH+"index.php?c=pay&a=submit&paynum="+$result;
				}
				else {
					$_error = $result;
					if ($_error.length == 0) {
						$_error = "提交失败，请检查";
					}
					ToastShow($_error);
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});

	});
	
	//申请退款
	$(document).on("click", "[f='but_app_refund']", function(){
		$_id = $(this).attr("data-id");
		$width = $(this).attr("data-width");
		if (typeof($width) == "undefined") {
			$width = 550;
		}
		$height = $(this).attr("data-height");
		if (typeof($height) == "undefined") {
			$height = 350;
		}
		$_url = _ROOT_PATH+"index.php?m=user&c=party&a=refund&id="+$_id+"&r="+get_rndnum(8);
		oeShadeBox("pop_refund_party", "ajax", $_url, $width, $height);
	});

	//提交申请
	$(document).on("click", "[f='but_save_apprefund']", function(){
		$_bmid = $(this).attr("data-id");
		$_idrz = $(this).attr("data-idrz");
		if ($_idrz == "0") {
			ToastShow("对不起，您还没实名认证，不能申请退款！");
			return false;
		}
		$payword = $("#payword").val();
		/*
		$bankname = $("#bankname").val();
		$banksub = $("#banksub").val();
		$bankaccount = $("#bankaccount").val();
		$payword = $("#payword").val();
		if ($bankname.length == 0) {
			ToastShow("请填写收款开户行");
			return false;
		}
		if ($bankaccount.length == 0) {
			ToastShow("请填写收款人账号");
			return false;
		}
		*/
		if ($payword.length == 0) {
			ToastShow("请输入安全密码");
			return false;
		}
		$.ajax({
			type: "POST",
			url: _OE_FILE+"&c=party",
			cache: false,
			data: {
					a:"saveapp", id:$_bmid, payword:$payword, r:get_rndnum(8)
			},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					ToastShow("申请成功，请等待网站处理");
					setTimeout(function(){
						window.location.reload();
					}, 500);
				}
				else {
					$_error = $result;
					if ($_error.length == 0) {
						$_error = "申请失败，请检查";
					}
					ToastShow($_error);
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});

	});

	//显示隐藏提示
	$(document).on("mouseover", "[f='but_show_refundtips']", function(){
		if ($(this).find("span").css("display") == "none") {
			$(this).find("span").show();
		}
	});
	$(document).on("mouseout", "[f='but_show_refundtips']", function(){
		if ($(this).find("span").css("display") == "block") {
			$(this).find("span").hide();
		}
	});

});
